<div class="row">
  <div class="col-md-12 col-xs-12">

    <h3>员工</h3>

    <div class="row m-b-10">
      <div class="col-md-4">
        <%= link_to '添加员工', new_staff_path, class: 'btn btn-default' if can? :create, User %>
      </div>

      <div class="col-md-8">
        <%= search_form_for @q, url: staffs_path, html: {class: 'pull-right form-inline'} do |f| %>
            <div class="form-group">
              <label>姓名</label>
              <%= f.search_field :name_cont, class: 'form-control' %>
            </div>
            <div class="form-group">
              <label>手机</label>
              <%= f.search_field :phone_cont, class: 'form-control' %>
            </div>
            <%= f.button class: 'btn btn-default' do %>
                <i class="glyphicon glyphicon-search"></i> 查询
            <% end %>
        <% end %>
      </div>
    </div>


    <table class="table table-striped table-bordered">
      <thead>
      <tr class="info">
        <th>编号</th>
        <th>姓名</th>
        <th>邮箱</th>
        <th>手机</th>
        <th>微信号</th>
        <th>微信昵称</th>
        <th>角色</th>
        <th>操作</th>
      </tr>
      </thead>

      <tbody>
      <% @users.each do |user| %>
          <tr>
            <td><%= user.id %></td>
            <td><%= user.name %></td>
            <td>
              <%= user.email %>
              <% if user.confirmed_at %>
                  <i class="glyphicon glyphicon-ok green" title="已验证"></i>
              <% else %>
                  未验证
              <% end %>
            </td>
            <td><%= user.phone %></td>
            <td><%= user.wechat %></td>
            <td>
              <%= user.wechat_nickname %>
              <% if user.wechat_openid %>
                  <i class="glyphicon glyphicon-ok green" title="已绑定"></i>
              <% end %>
            </td>
            <td><%= user.role_name %></td>
            <td>
              <%= link_to '详情', staff_path(user) %>

              <% unless user.admin? %>
                  <%= link_to '编辑', edit_staff_path(user) if can? :update, user %>
                  <%= link_to '修改密码', password_staff_path(user) if can? :password, user %>
                  <%= link_to '删除', staff_path(user), method: :delete, data: {confirm: '确定删除?'} if can? :destroy, user %>
              <% end %>
            </td>
          </tr>
      <% end %>
      </tbody>
    </table>

    <%= render partial: 'shared/paginate', locals: {collection: @users} %>

    <div class="well well-sm">
      温馨提示：
      <ul>
        <li>
          条件员工后会给员工的邮箱发送一封验证邮件，邮箱验证后才可以登录。
        </li>
        <li>
          绑定微信号后才可以通过微信进行登录、获取销售奖励等操作。
        </li>
      </ul>
    </div>

  </div>
</div>
